package org.zhou.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.zhou.mapper.UserMapper;
import org.zhou.pojo.User;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private UserMapper userMapper;


    @GetMapping("/queryUserList")
    public List<User> queryUserList(){
        List<User> users = userMapper.queryUserList();
        return users;
    }
    @GetMapping("/queryUserById")
    public User queryUserById(@PathVariable("id") Integer id){
        User user = userMapper.queryUserById(id);
        return user;
    }

    @GetMapping("/addUser")
    public String addUser(){
         userMapper.addUser(new User(7,"zhou","238723"));
        return "ok";
    }
    @GetMapping("/updateUser")
    public String updateUser(User user){
         userMapper.updateUser(new User(7,"zhou","78349823"));
        return "ok";
    }
    @GetMapping("/deleteUserById")
    public String deleteUserById(){
       userMapper.deleteUserById(7);
        return "ok";
    }

}
